package com.api.shopapi.mapper;

import com.api.shopapi.entity.DishesPlanMorningItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface DishesPlanMorningItemMapper {


    @Insert("insert into dishes_plan_morning_item" +
            "(" +
            "DishesPlanMorningItemCode," +
            "DishesPlanMorningCode," +
            "DishesCode," +
            "DishesName" +
            ") " +
            "values" +
            "(" +
            "#{dishesPlanMorningItem.DishesPlanMorningItemCode}," +
            "#{dishesPlanMorningItem.DishesPlanMorningCode}," +
            "#{dishesPlanMorningItem.DishesCode}," +
            "#{dishesPlanMorningItem.DishesName}" +
            ")")
    int insert(@Param("dishesPlanMorningItem") DishesPlanMorningItem dishesPlanMorningItem);

    @Delete("delete from dishes_plan_morning_item where dishesPlanMorningItemCode=#{dishesPlanMorningItemCode}")
    int delete(@Param("dishesPlanMorningItemCode") String dishesPlanMorningItemCode);

    @Update("update dishes_plan_morning_item" +
            " set" +
            " DishesCode=#{dishesPlanMorningItem.DishesCode}" +
            " where " +
            " DishesPlanMorningItemCode=#{dishesPlanMorningItem.DishesPlanMorningItemCode}")
    int update(@Param("dishesPlanMorningItem") DishesPlanMorningItem dishesPlanMorningItem);

    @Select("select * from dishes_plan_morning_item where dishesPlanMorningItemCode=#{dishesPlanMorningItemCode} limit 1")
    DishesPlanMorningItem getByDishesPlanMorningItemCode(@Param("dishesPlanMorningItemCode") String dishesPlanMorningItemCode);

    @Select("<script>" +
            "select * from dishes_plan_morning_item where dishesPlanMorningCode=#{dishesPlanMorningCode} " +
            "</script>")
    List<DishesPlanMorningItem> ListByDishesPlanMorningCode(@Param("dishesPlanMorningCode") String dishesPlanMorningCode);

}
